import request from '../utils/request'

export function requestUnReadCount () {
    return new Promise(resolve => {
        request.get('/message/count', {
            params: {
                userid: localStorage.getItem('userid') || ''
            }
        }).then(res => {
            resolve(res.data)
        })
    })
}

export function requestUnReadList () {
    return new Promise(resolve => {
        request.get('/message/unreadlist', {
            params: {
                userid: localStorage.getItem('userid') || ''
            }
        }).then(res => {
            resolve(res.data)
        })
    })
}

export function requestReadList () {
    return new Promise(resolve => {
        request.get('/message/readlist', {
            params: {
                userid: localStorage.getItem('userid') || ''
            }
        }).then(res => {
            resolve(res.data)
        })
    })
}

export function requestReadMsg (msgid) {
    return new Promise(resolve => {
        request.post('/message/readit', {
            msgid,
            userid: localStorage.getItem('userid') || ''
        }).then(res => {
            resolve(res.data)
        })
    })
}
